import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		isLogin: false,
		userInfo: {},
		orderType: 'takein',
		choseAddress: {},
		chooseStore: {},
		orderCurrent: {}
	},
	getters: {
		isLogin: state => Object.keys(state.userInfo).length > 0 //是否登录
	},
	mutations: {
		Login(state, res) {
			state.isLogin = true
			state.userInfo = res
			console.log('res==>', res)
			uni.setStorage({
				key: 'userInfo',
				data: res
			})
		},
		SET_ORDER_TYPE(state, type) {
			state.orderType = type
		},
		SET_ADDRESS(state, address) {
			state.choseAddress = address
		},
		SET_STORE(state, store) {
			state.chooseStore = store
		},
		SET_ORDER_CURRENT(state,current) {
			state.orderCurrent = current
		},
		CHEAR_CURRENT(state) {
			state.orderCurrent = {}
		},
		SET_ORDER_CURRENT_STATUS(state, status) {
			state.orderCurrent.status = status
		}
	},
	actions: {}
})

export default store;
